package com.sunwayhorizo.health.platform.security.persistent;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import com.sunwayhorizo.health.platform.util.BeanHelper;

@Entity
@TableGenerator(name = "SecurityAccountRole_IdGenerator", table = "ET_Id_Generator", pkColumnName = "pkColumn", valueColumnName = "valueColumn", pkColumnValue = "SECURITY_ACCOUNT_ROLE_ID",allocationSize=1)
@Table(name = "SECURITY_ACCOUNT_ROLE", schema = "ETS")
public class SecurityAccountRole implements java.io.Serializable {
	
	@Id
	@GeneratedValue(strategy = GenerationType.TABLE,generator="SecurityAccountRole_IdGenerator")
	@Column(name = "ACCOUNT_ROLE_ID", unique = true, nullable = false, length = 32)
	private String accountRoleId;
	
	@ManyToOne
	@JoinColumn(name = "ROLE_ID")
	private SecurityRole role;
	
	@ManyToOne
	@JoinColumn(name = "ACCOUNT_ID")
	private SecurityAccount account;

	public SecurityAccountRole() {
	}

	public SecurityAccountRole(String accountRoleId) {
		this.accountRoleId = accountRoleId;
	}

	public SecurityAccountRole(String accountRoleId, SecurityRole role,
			SecurityAccount account) {
		this.accountRoleId = accountRoleId;
		this.role = role;
		this.account = account;
	}

	public String getAccountRoleId() {
		return this.accountRoleId;
	}

	public void setAccountRoleId(String accountRoleId) {
		this.accountRoleId = accountRoleId;
	}

	public SecurityRole getRole() {
		return this.role;
	}

	public void setRole(SecurityRole role) {
		this.role = role;
	}

	public SecurityAccount getAccount() {
		return this.account;
	}

	public void setAccount(SecurityAccount account) {
		this.account = account;
	}
	
	@Override
	public String toString() {
		return BeanHelper.toString(this);
	}
}
